<?php
require_once("database.php");
class xl_position extends database
{
	function danh_sach($vi_tri, $so_luong)
	{
		$vi_tri = intval($vi_tri);
		$so_luong = intval($so_luong);
		$sql = "select * from position limit $vi_tri, $so_luong";
		$this->setQuery($sql);
		return $this->loadAllRow();
	}
	function so_luong()
	{
		$sql = "select count(*) from position";
		$this->setQuery($sql);
		return $this->loadResult();
	}
	function xem($pid)
	{
		
		$sql = "select * from position where pid = '$pid'";
		$this->setQuery($sql);
		return $this->loadRow();
	}
	function xoa($pid)
	{
		
		$sql = "delete from position where pid = '$pid'";
		$this->setQuery($sql);
		$this->query();
	}
	function them($pname)
	{
		$pname = addslashes($pname);

		$sql = "INSERT INTO position(pname) VALUES ('$pname')";
		$this->setQuery($sql);
		return $this->query();
	}
	function cap_nhat($pid, $pname)
	{
		$pname = addslashes($pname);

		$sql ="UPDATE position SET pname= '$pname' WHERE pid = '$pid'";
		$this->setQuery($sql);
		return $this->query();
	}
	function tim_kiem ($tu_khoa)
	{
		$sql = "select * from position where	$pname like %tu_khoa%"; 
		$this->setQuery($sql);
		return $this->loadAllRow();	
	}
 }
?>